package IO.io_5_9;

import java.io.*;
import java.util.Scanner;

/**
 * @author bruin_du
 * @description 替换字符串工具
 * @date 2022/5/12 15:29
 **/
public class ReplaceTool {
    public static void main(String[] args) throws IOException {
        try(InputStream is = new FileInputStream("src.txt")){
            try(Scanner scanner = new Scanner(is,"UTF-8")){
                try(OutputStream os = new FileOutputStream("dest.txt")){
                    try(Writer writer = new OutputStreamWriter(os,"UTF-8")){
                        try(PrintWriter printWriter = new PrintWriter(writer)){
                            while(scanner.hasNextLine()){
                                String str = scanner.nextLine();
                                String replace = str.replace("你好","我好");
                                printWriter.println(replace);
                            }
                            printWriter.flush();
                        }
                    }
                }
            }
        }
    }
}
